﻿#ifndef HANDLER_H
#define HANDLER_H

#include "head/g_functionbase.h"

#define ACT_NULL 0
#define ACT_SCAN 1
#define ACT_COPY 2
#define ACT_MOVE 3
#define ACT_DELETE 4
#define ACT_MD5 5
#define ACT_SHA1 6
#define ACT_SHA256 7

/* config.json example
 * {
    "source":".",
    "destination":"",
    "action":"scan",
    "sep":"\t",
    "filter":["*.exe"]
   }
*/

class Handler : public QObject
{
    Q_OBJECT

public:
    explicit Handler(QObject *parent = 0);

    void read_config(const QString &filePath);
    QString prepare(const QString &source);
    void operate(int action,const QString &source,const QString &destination,
                 const QStringList &nameFilters);
    void scan(const QString &source,const QString &destination,
              const QStringList &nameFilters);
    void scanOption(const QJsonObject &obj);
    void move(const QString &source,const QString &destination,
              const QStringList &nameFilters);
    void copy(const QString &source,const QString &destination,
              const QStringList &nameFilters);
    void remove(const QString &source,const QStringList &nameFilters);
    void verify_sha1(const QString &source,const QString &destination,
                     const QStringList &nameFilters);
private:
    QString separator;
};

#endif // HANDLER_H
